<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <title>飞妈-注册</title>
    <script src="__ROOT__/Public/Home/js/jquery-3.1.0.min.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" type="text/css" href="__ROOT__/Public/Home/css/recommend.css?t=23" />
</head>

<body>



<div class="warp">


    <div class="inp">
        <div class="bag">
            <p>

                <input class="codep Iphone" type="text" placeholder="输入手机号注册" />


            </p>
            <p class="bagpp">

                <input class="Icode" type="text" placeholder="请输入验证码" />
                <big class="codem">获取验证码</big>

            </p>
            <p>

                <input class="Ipassword" type="password" placeholder="请设置密码" />

            </p>

        </div>
    </div>


    <p class="islogin">
        <button class="RegOK">立即注册</button>
    </p>
    <p class="introduce">
        飞妈-让所有人都能开飞机游艇！
    </p>
    <div class="zhezhao"></div>

    <div class="tishia">
        <div class="sdk">

        </div>
    </div>

</div>

<script type="text/javascript">
    document.onselectstart = new Function("event.returnValue=false");
    if(top.location != self.location) top.location = self.location;
    $.extend({
        F_SIZE: function(size) {
            var $html = $('html');
            var $window = $('window');
            var $body = $('body');
            var psdsize = size;
            var htmlfont = $body.width() / psdsize * 100 + 'px';
            $html.css('font-size', htmlfont);
            $body.css('opacity', 1);
            $(window).resize(function(event) {
                htmlfont = $body.width() / psdsize * 100 + 'px';
                $html.css('font-size', htmlfont);

            });
        }
    });
    $.F_SIZE(750);
</script>

<script type="text/javascript">
    $('.warp').height(document.body.scrollHeight);

    function golast() {
        window.history.go(-1)
    }


    function golast2() {
        $(".warp").show();
        $(".warpOK").hide()
    }
    var IAPI = "{$sms_url}";
    var WAPI = '{$reg_url}';
    var Iapiversion = 'v.1.0';

    function hrefs(){
        var param = {};
        var newparam = JSON.stringify(param);
        var sendsms = {
            apiversion: Iapiversion,
            handler: 'User',
            method: 'downloadinfo',
            param: newparam
        };
        $.post(IAPI, sendsms).then(function(data) {
            console.log(data)
        })
    }
    //			hrefs()

    //发送短信
    $('.codem').click(function() {
        console.log($('.Iphone').val());
        var param = {
            phone: $('.Iphone').val(),
            type: 1,
//            user_id: {$id},
        };
        var newparam = JSON.stringify(param);
        var sendsms = {
            apiversion: Iapiversion,
            uuid: 'b28ad67b6e127841',
            nonce: 'IVpCn0h53FEQcgmTcKftpXS5DzYMXZgN',
            sign: 'CaMRZI7902Po7Uf6GFQdy8JrKNYlM2m01Qp7M7UhFgUFNRg0O2b1RFAoD6t6vAbQj5s3+Qwa979bLLUpKEz0oLXEoLPy4WvE5gi+NhvyQL+s+OmTjVB+fw/MVq7okY7GG/nNXgjrnRguQSijmUD+VwkXuBHfN075sTcU+mr6fhLJqx8wUziLGv5dTE805a6xZhMbOhjsX3n0skspA78kNg==',
            handler: 'Api',
            method: 'sendsms',
            param: newparam,
        };

        var Gettime = '60';
        var Getcodetime = '获取验证码';
        $.post(IAPI, sendsms).then(function(data) {
            console.log(data);

            tishia(data.data.error_msg);

            if(data.code == 200) {
                $(".zhezhao").show();

                if(Gettime >= 60) {
                    var set = setInterval(function() {
                        Gettime = Gettime - 1;

                        Getcodetime = Gettime;
                        $(".codem").text(Getcodetime);
                        if(Gettime <= 0) {
                            //计时器停止
                            Getcodetime = '獲取驗證碼';
                            $(".codem").text(Getcodetime);
                            Gettime = 60;
                            $(".zhezhao").hide();
                            clearInterval(set);
                        }
                    }, 1000)
                }
                localStorage.sendtime = data.data.obj.sendtime
            }else if(data.code == 405){

                if(data.data.error==100002){
                    $('.cono').show()
                }
            }
        })
    });


    $('.Close').click(function() {
        $('.cono').hide()
    });

    $('.RegOK').click(function() {

        if($('.Iphone').val() == '' || $('.Iphone').val() == undefined) {
            tishia('手機號不能為空')
            return
        }
        if($('.Icode').val() == '' || $('.Icode').val() == undefined) {
            tishia('驗證碼不能爲空')
            return
        }
        if($('.Ipassword').val() == '' || $('.Ipassword').val() == undefined) {
            tishia('密碼不能爲空')
            return
        }

//        var url = "{$reg_url}";
//        var loc = url.substring(url.lastIndexOf('=') + 1, url.length);
//        console.log(loc)

        var param = {
            phone: $('.Iphone').val(),
            password: $('.Ipassword').val(),
            smscode: $('.Icode').val(),
            uid: "{$id}",
        };
        var newparam = JSON.stringify(param);
        var register = {
            apiversion: Iapiversion,
            uuid: 'b28ad67b6e127841',
            nonce: 'IVpCn0h53FEQcgmTcKftpXS5DzYMXZgN',
            sign: 'CaMRZI7902Po7Uf6GFQdy8JrKNYlM2m01Qp7M7UhFgUFNRg0O2b1RFAoD6t6vAbQj5s3+Qwa979bLLUpKEz0oLXEoLPy4WvE5gi+NhvyQL+s+OmTjVB+fw/MVq7okY7GG/nNXgjrnRguQSijmUD+VwkXuBHfN075sTcU+mr6fhLJqx8wUziLGv5dTE805a6xZhMbOhjsX3n0skspA78kNg==',
            handler: 'H5',
            method: 'register',
            param: newparam,
        };

        $.post(IAPI, register).then(function(data) {

//            tishia(data.data.error_msg)
//            if(data.code == 200) {
//
//                localStorage.phone = v.phone
//                localStorage.password = v.password1
//            }


            console.log(data);

            tishia(data.data.error_msg);

            if(data.code == 200) {
                $(".zhezhao").show();
                localStorage.phone = v.phone
                localStorage.password = v.password1
            }else if(data.code == 405){

                if(data.data.error==100002){
                    $('.cono').show()
                }
            }


        })

    });

    function tishia(ccc) {
        $(".tishia").show()
        $(".tishia .sdk").text(ccc)
        setTimeout(function() {
            $(".tishia").hide()
        }, 1000)
    }
</script>
</body>

</html>